package JmmAndMultiThread;

public class JmmVolatileAtomic {
    private static volatile int counter=0;
    public static void main(String[] args) {
        for (int i=0;i<10;i++)
        {
            new Thread(()->{
                for (int j=0;j<1000;j++){
                    counter++;
                }
            }).start();
        }
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //counter<=10000
        System.out.println("counter = [" + counter + "]");
    }
}
